package com.gluck.cases.core.modal.assemble;

import com.gluck.cases.common.utils.utils.TimeUtils;
import com.gluck.cases.core.modal.dto.CasesGroupDTO;
import com.gluck.cases.core.modal.entity.CasesGroup;
import com.gluck.cases.core.modal.req.CasesGroupReq;

import java.time.LocalDateTime;

/**
 * @ClassName CasesGroupAssemble
 * @Desc CasesGroup 组装类
 * @Author shiyongzhe
 * @Date 2022/6/2 - 9:59 下午
 **/
public class CasesGroupAssemble {

    public static CasesGroup CasesGroupDTOConvertCasesGroup(CasesGroupDTO dto){
        CasesGroup casesGroup = new CasesGroup();
        casesGroup.setCasesApis(dto.getCasesIds());
        casesGroup.setCreatedBy(dto.getCreatedBy());
        casesGroup.setCreatedAt(LocalDateTime.now());
        casesGroup.setName(dto.getName());
        return casesGroup;
    }

    public static CasesGroupDTO CasesGroupConvertDTO(CasesGroup casesGroup){
        CasesGroupDTO dto = new CasesGroupDTO();
        dto.setCasesIds(casesGroup.getCasesApis());
        dto.setName(casesGroup.getName());
        dto.setGid(casesGroup.getId());
        dto.setCreatedBy(casesGroup.getCreatedBy());
        dto.setCreatedAt(TimeUtils.format(casesGroup.getCreatedAt(), TimeUtils.DATETIME_FORMATTER));
        return dto;
    }

    public static CasesGroupDTO CasesGroupReqConvertDTO(CasesGroupReq req){
        CasesGroupDTO dto = new CasesGroupDTO();
        dto.setCreatedBy(req.getCreatedBy());
        dto.setName(req.getName());
        dto.setStatus(req.getStatus());
        dto.setGid(req.getId());
        return dto;
    }
}
